/*
 * NotaRender.java
 *
 * Created on 18-dic-2007, 22:18:41
 *
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jschoolmanagerportable.gui.model;

import java.awt.Color;
import java.text.DecimalFormat;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Administrador
 */
public class NotaRender extends DefaultTableCellRenderer {

    DecimalFormat formatter;

    public NotaRender() {
        super();
        this.setHorizontalAlignment(SwingConstants.CENTER);
    }

    public void setValue(Object value) {
        if (formatter == null) {
            formatter = new DecimalFormat("#,#");
        }
        double nota=0;
        if(value != null){
            nota = Double.valueOf(String.valueOf(value));
        }
        String str = String.valueOf(value).replace('.', ',');
        setText(str);
        
        if(nota<4.0){
            this.setForeground(Color.RED);
        }else{
            this.setForeground(Color.BLUE);
        }
    }
}